package com.zr.controller.base;

import java.io.IOException;
import com.zr.utils.AjaxResult;
import javax.annotation.Resource;
import com.zr.vo.base.BaseDriver;
import com.zr.service.base.BaseDriverPhotoService;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 司机备证照片上传和回显
 */
@RestController
@RequestMapping("/baseDriverPhoto")
public class BaseDriverPhotoController {

    @Resource
    private BaseDriverPhotoService baseDriverPhotoService;

    /**
     * 上传司机备证图片信息
     * @param files
     * @return
     * @throws IOException
     * @author liutienan
     */
    @RequestMapping("/uploadImg")
    public AjaxResult uploadImg(@RequestParam("file") MultipartFile[] files, @RequestParam("driver") String driverId) throws IOException {
        return AjaxResult.success(200, "上传成功", baseDriverPhotoService.uploadImg(files,driverId));
    }

    /**
     * 司机备证照片列表
     * @param baseDriver
     * @return
     * @throws IOException
     * @author liutienan
     */
    @RequestMapping("/plist")
    public AjaxResult showDriverPhotos( @RequestBody BaseDriver baseDriver) throws IOException {
        return AjaxResult.success(200, "显示图片成功", baseDriverPhotoService.showDriverPhotos(baseDriver.getDriverId()));
    }
}
